<?php
class sfMatNewsValidatedFile extends sfValidatedFile
{
  public function save($file = null, $fileMode = 0666, $create = true, $dirMode = 0777)
  {
     //$this->path=sfConfig::get('sf_upload_dir')."/material/gallery";
    $file_name = parent::save($file, $fileMode, $create, $dirMode);

    //Обжим
    $this->generateThumbnail ( $file_name );
    $this->generateThumbnailsmall ( $file_name );
    
    /////
    
    return $file_name;
  }
  
public function generateThumbnail($value) 

	{
		@unlink($uploadDir . '/material/news/thumbnail/' . $value);
		$uploadDir = sfConfig::get ( 'sf_upload_dir' );
		$thumbnail = new sfThumbnail ( 200, 200 );
		$thumbnail->loadFile ( $uploadDir . '/material/news/' . $value );
		$thumbnail->save ( $uploadDir . '/material/news/thumbnail/' . $value );
	
	}
	
public function generateThumbnailsmall($value) 

	{
		@unlink($uploadDir . '/material/news/_thumbnail/' . $value);
		$uploadDir = sfConfig::get ( 'sf_upload_dir' );
		$thumbnail = new sfThumbnail ( 100, 100 );
		$thumbnail->loadFile ( $uploadDir . '/material/news/' . $value );
		$thumbnail->save ( $uploadDir . '/material/news/_thumbnail/' . $value );
	
	}	
	
	
	
}